package 集合框架;

import java.util.*;

public class EntryTest {
    public static void main(String[] args) {
        Map<Integer,String>map=new HashMap();
        map.put(1,"1");
        map.put(3,"@");
        map.put(6,"#");
        List<Map.Entry<Integer,String>>list=new ArrayList<>(map.entrySet());
        Collections.sort(list, new Comparator<Map.Entry<Integer, String>>() {
            @Override
            public int compare(Map.Entry<Integer, String> o1, Map.Entry<Integer, String> o2) {

                if (o1.getKey()>o2.getKey()){
                    return 1;
                }else if (o1.getKey()<o2.getKey()){
                    return -1;
                }else {
                    return 0;
                }
            }
        });
        System.out.println(list);

    }
}
